package com.tang.ack.controller;

import com.tang.ack.provider.RabbitMqLogErrorProduce;
import com.tang.ack.provider.RabbitMqLogInfoProduce;
import org.springframework.web.bind.annotation.*;

@RestController
public class SendMsgController {

    private final RabbitMqLogInfoProduce rabbitMqLogInfoProduce;

    private final RabbitMqLogErrorProduce rabbitMqLogErrorProduce;

    public SendMsgController(RabbitMqLogInfoProduce rabbitMqLogInfoProduce,
                             RabbitMqLogErrorProduce rabbitMqLogErrorProduce) {
        this.rabbitMqLogInfoProduce = rabbitMqLogInfoProduce;
        this.rabbitMqLogErrorProduce = rabbitMqLogErrorProduce;
    }

    @RequestMapping(value = "/logInfo")
    public String rabbitmqSendLogInfoMessage() {
        String msg = "生产者===>生者的LogInfo消息message: ";
        for (int i = 0; i < 100000; i++) {
            rabbitMqLogInfoProduce.producer(msg + i);
        }
        return "生产===>  LogInfo消息message  ===> success!!!";
    }

    @PostMapping(value = "/logError")
    public String rabbitmqSendLogErrorMessage(@RequestBody String msg) {
        rabbitMqLogErrorProduce.producer(msg);
        return "生产===>  LogError消息message  ===> success!!!";
    }

}
